XHR.js ➔ postXML   A
last analyzed

Complexity

Conditions 3

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
c 0
b 0
f 0
dl 0
loc 12
rs 9.9
cc 3
1
/*
2
 * *****************************************************************************
3
 * Contributions to this work were made on behalf of the GÉANT project, a 
4
 * project that has received funding from the European Union’s Framework 
5
 * Programme 7 under Grant Agreements No. 238875 (GN3) and No. 605243 (GN3plus),
6
 * Horizon 2020 research and innovation programme under Grant Agreements No. 
7
 * 691567 (GN4-1) and No. 731122 (GN4-2).
8
 * On behalf of the aforementioned projects, GEANT Association is the sole owner
9
 * of the copyright in all material which was developed by a member of the GÉANT
10
 * project. GÉANT Vereniging (Association) is registered with the Chamber of 
11
 * Commerce in Amsterdam with registration number 40535155 and operates in the 
12
 * UK as a branch of GÉANT Vereniging.
13
 * 
14
 * Registered office: Hoekenrode 3, 1102BR Amsterdam, The Netherlands. 
15
 * UK branch address: City House, 126-130 Hills Road, Cambridge CB2 1PQ, UK
16
 *
17
 * License: see the web/copyright.inc.php file in the file structure or
18
 *          <base_url>/copyright.php after deploying the software
19
 */
20
21
function postXML(funct, form) {
22
    var client = new XMLHttpRequest();
23
    client.onreadystatechange = funct;
24
    client.open("POST", form.action);
25
    client.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
26
    var form_values = "";
27
    var elementlength = form.elements.length;
28
    for (var i = 0; i < elementlength; i++) {
29
        form_values = form_values + (form_values === "" ? "" : "&") + encodeURIComponent(form.elements[i].name) + "=" + encodeURIComponent(form.elements[i].value);
30
    }
31
    client.send(form_values);
32
}
33